Article View: comp.sys.intel
Article #1926Re: PLM vs. C for 80286/80386
From: Tom Neff
Date: Wed, 07 Jun 1989 15:28
Date: Wed, 07 Jun 1989 15:28
104 lines
5065 bytes
5065 bytes
In article <1765@auspex.auspex.com> guy@auspex.auspex.com (Guy Harris) writes:
> [ I had said: ]
>>For instance if you want a CASE driven state machine in a critical
>>interrupt handler, PL/M implements DO CASE as a jump indirect indexed
>>off a short array of offsets, e.g. JMP CASETBL[BX]. C on the other hand
>>does 'switch' as a full if-then/elseif-then/elseif-then... series.
>
>I sincerely hope Intel's C compiler does not do so for *all* "switch"
>statements; any competent C compiler can and will turn a "dense"
>"switch" statement - i.e., one where the cases form a reasonably tight
>range - into an indexded jump. (The definition of "dense" varies from
>compiler to compiler.)
Not wanting to make rash statements, I retested it. I'm right. Here's
the proof (about 70 lines so hit N if you believe me <grin>):
iC-86 COMPILER JUNK 05/27/89 11:23:32 PAGE 1
DOS 3.30 (038-N) iC-86 COMPILER V4.0, COMPILATION OF MODULE JUNK
OBJECT MODULE PLACED IN JUNK.OBJ
COMPILER INVOKED BY: Z:\L86\IC86.EXE JUNK.C OPTIMIZE(3) CODE PAGEWIDTH(80)
line level incl
1 main()
2 {
3 1 int x;
4 1
5 1 switch (x) {
6 2 case 0: foo(x);
7 2 break;
8 2 case 1: fee(x);
9 2 break;
10 2 case 2: fie(x);
11 2 break;
12 2 }
13 1 }
iC-86 COMPILER JUNK 05/27/89 11:23:32 PAGE 2
ASSEMBLY LISTING OF OBJECT CODE
; STATEMENT # 2
main PROC NEAR
0000 56 PUSH SI
0001 57 PUSH DI
0002 55 PUSH BP
0003 8BEC MOV BP,SP
0005 51 PUSH CX
; STATEMENT # 5
0006 8B5EFE MOV BX,[BP].x
0009 EB19 JMP @3
@4:
; STATEMENT # 6
000B FF76FE PUSH [BP].x ; 1
000E E80000 CALL foo
0011 EB0E JMP @7
; STATEMENT # 7
@5:
; STATEMENT # 8
0013 FF76FE PUSH [BP].x ; 1
0016 E80000 CALL fee
0019 EB06 JMP @7
; STATEMENT # 9
@6:
; STATEMENT # 10
001B FF76FE PUSH [BP].x ; 1
001E E80000 CALL fie
@7:
0021 59 POP CX ; 1
; STATEMENT # 11
0022 EB0F JMP @2
; STATEMENT # 12
@3:
0024 83FB00 CMP BX,0H
0027 74E2 JZ @4
0029 83FB01 CMP BX,1H
002C 74E5 JZ @5
002E 83FB02 CMP BX,2H
0031 74E8 JZ @6
@2:
; STATEMENT # 13
0033 8BE5 MOV SP,BP
0035 5D POP BP
0036 5F POP DI
0037 5E POP SI
0038 C3 RET
main ENDP
MODULE INFORMATION:
CODE AREA SIZE = 0039H 57D
CONSTANT AREA SIZE = 0000H 0D
DATA AREA SIZE = 0000H 0D
MAXIMUM STACK SIZE = 000CH 12D
iC-86 COMPILER JUNK 05/27/89 11:23:32 PAGE 3
ASSEMBLY LISTING OF OBJECT CODE
iC-86 COMPILATION COMPLETE. 0 WARNINGS, 0 ERRORS
--
You may redistribute this article only to those who may freely do likewise.
--
Tom Neff UUCP: ...!uunet!bfmny0!tneff
"Truisms aren't everything." Internet: tneff@bfmny0.UU.NET
Technical Details
Message-ID:
<14386@bfmny0.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!bfmny0!tneffReferences:
<598@philtis.UUCP> <14381@bfmny0.UUCP> <1765@auspex.auspex.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!bfmny0!tneff From: tneff@bfmny0.UUCP (Tom Neff) Newsgroups: comp.sys.intel Subject: Re: PLM vs. C for 80286/80386 Keywords: PLM C Message-ID: <14386@bfmny0.UUCP> Date: 7 Jun 89 15:28:45 GMT References: <598@philtis.UUCP> <14381@bfmny0.UUCP> <1765@auspex.auspex.com> Reply-To: tneff@bfmny0.UUCP (Tom Neff) Organization: ^ Lines: 104